<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="minipost.post.model.Post"%>
<%@ page import="minipost.post.PostBean"%>
<%
	request.setCharacterEncoding("UTF-8");

	Object user = session.getAttribute("user");
	if (user == null) {
		response.sendRedirect("login.jsp");
	} else {
		String id = request.getParameter("id");
		PostBean postBean = new PostBean();
		Post post = postBean.getPostById(Integer.parseInt(id));
%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>管理</title>
    <link rel="stylesheet" type="text/css" href="css/admin.css"/>
    
    <script type="text/javascript" src="js/jquery.js"></script>
    <link rel="stylesheet" href="kindeditor/themes/default/default.css" />
    <link rel="stylesheet" href="kindeditor/plugins/code/prettify.css" />
    <script charset="utf-8" src="kindeditor/kindeditor.js"></script>
    <script charset="utf-8" src="kindeditor/lang/zh_CN.js"></script>
    <script charset="utf-8" src="kindeditor/plugins/code/prettify.js"></script>
    <script type="text/javascript">
    KindEditor.ready(function(K) {
        	var editor1 = K.create('textarea[name="input-content"]', {
            	resizeType : 1,
                allowPreviewEmoticons : false,
                allowImageUpload : false,
                items : [
                    'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                    'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                    'insertunorderedlist', '|', 'emoticons', 'link']
            });
            prettyPrint();
        });
    </script>
</head>
<body>
    <div id="head">
        <P>管理</P>
    </div>
    <div id="nav">
        <ul>
            <li><a href="index.jsp">首页</a></li>
            <li><a href="publish.jsp">发表文章</a></li>
            <li><a href="management.jsp">文章管理</a></li>
            <li><a href="xgmm.jsp">修改密码</a></li>
            <li><a href="login.jsp">退出管理</a></li>
        </ul>
    </div>
    <div id="mid">
        <div class="content">
            <form action="/minipost/adminServlet?type=edit&id=<%= id%>" method="post">
                <div class="row">
                    <label for="title">题目</label>
                </div>
                <div class="row">
                    <input type="text" name="title" id="title" value="<%= post.getPostTitle()%>"/>
                </div>
                <div class="row">
                    <label for="title">来源</label>
                </div>
                <div class="row">
                    <input type="text" name="from" id="from" value="<%=post.getPostAuthor() %>" />
                </div>
                <div class="row">
                    <label for="category">分类</label>
                </div>
                <div class="row">
                    <select id="category" name="category">
                        <option value="国内"<%= post.getPostType().equals("国内") ? " selected=\"selected\"" : ""%>>国内</option>
                        <option value="国外"<%= post.getPostType().equals("国外") ? " selected=\"selected\"" : ""%>>国外</option>
                        <option value="社会"<%= post.getPostType().equals("社会") ? " selected=\"selected\"" : ""%>>社会</option>
                        <option value="科技"<%= post.getPostType().equals("科技") ? " selected=\"selected\"" : ""%>>科技</option>
                    </select>
                </div>
                <div class="row">
                    <label for="input-content">内容</label>
                </div>
                <div class="row">
                    <textarea id="input-content" name="input-content"><%=post.getPostContent()%></textarea>
                </div>
                <div class="row">
                    <input type="submit" id="submit" name="submit" value="提交" />
                </div>
            </form>
        </div>
    </div>
    <div id="foot">
        Copyright&copy;&nbsp;合肥工业大学网站设计基础
    </div>
</body>
</html>

<%
	}
%>	